#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
int a[N];
struct Node {
  string s;
  int num;
  string expr;
};
Node dp[105][105];
string expr(string s, int num) {
  if (num == 1) return s;
  if ((s.size() == 1 && num <= 3) || (s.size() == 2 && num <= 2)) {
    string res;
    rep(i, 1, num) res += s;
    return res;
  } else {
    stringstream ss;
    ss << num << '(' << s << ')';
    return ss.str();
  }
}
Node newnode(string s, int num) {
  string t = expr(s, num);
  return Node{s, num, t};
}
bool cmp(Node a, Node b) {
  int lena = a.expr.size();
  int lenb = b.expr.size();
  return lena < lenb || (lena == lenb && a.num > b.num);
}
Node merge(Node a, Node b) {
  if (a.s == b.s) {
    return newnode(a.s, a.num + b.num);
  } else {
    return newnode(a.expr + b.expr, 1);
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  string s;
  cin >> s;
  n = s.size();
  rep(i, 0, n - 1) dp[i][i] = newnode(s.substr(i, 1), 1);
  rep(len, 2, n) {
    rep(l, 0, n - len) {
      int r = l + len - 1;
      dp[l][r].expr = s;
      rep(i, l, r - 1) {
        Node p = merge(dp[l][i], dp[i + 1][r]);
        if (cmp(p, dp[l][r])) dp[l][r] = p;
      }
    }
  }
  cout << dp[0][n - 1].expr.size();
  return 0;
}